﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;
namespace DAO
{
    public class Dataprovider
    {
        public static string connectinString = ConfigurationManager.ConnectionStrings["aspnetdbConnectionString"].ConnectionString;

        public static DataTable ExcuteQuery(string strSQL)
        {
            SqlConnection connect = new SqlConnection(connectinString);
            connect.Open();
            SqlDataAdapter da = new SqlDataAdapter(strSQL, connect);
            DataTable dt = new DataTable();
            da.Fill(dt);
            connect.Close();
            return dt;
        }
        public static string ExcuteScalar(string strSQL)
        {
            SqlConnection connect = new SqlConnection(connectinString);
            connect.Open();
            SqlCommand comm = new SqlCommand(strSQL, connect);
            comm.CommandText = strSQL;
            string gt = comm.ExecuteScalar().ToString();
            connect.Close();
            return gt;
        }
        public static int ExcuteNonQuery(string strSQL)
        {
            SqlConnection connect = new SqlConnection(connectinString);
            SqlCommand cmd = new SqlCommand(strSQL, connect);
            connect.Open();
            int r = cmd.ExecuteNonQuery();
            connect.Close();
            return r;
        }
        public static DataTable CallStore(String Sql)
        {
            SqlConnection connect = new SqlConnection(connectinString);
            SqlDataAdapter da = new SqlDataAdapter(Sql, connect);
            DataTable dt = new DataTable();
            da.Fill(dt);
            connect.Close();
            return dt;
        }
    }
}